<?php

class User_Action_Admin_Setting_Signup  extends Action_Admin
{
	function execute($request, $initial = TRUE, $script = NULL)
	{

		if ($initial)
		{
			Agilet::setVar('breadcrum', array(
				array(
					'url' => 'admin/user',
					'label' => 'User'
				),
				array(
					'url' => 'admin/user/setting',
					'label' => 'Setting'
				),
				array(
					'url' => 'admin/user/setting/signup',
					'label' => 'Signup'
				)
			));

		}

		$form = Form::factory('user/admin/setting/signup');

		$name = 'user.signup';

		if ($request -> isGet())
		{
			$config = Config::instance() -> read($name);
			
			$form -> setData($config->toArray());
		}

		if ($request -> isPost() && $form -> isValid($_POST))
		{
			$value = $form -> getData();

			unset($value['buttons']);


			// update configure
			Config::instance() -> write($name, $value);

			// add notice
			$form -> setNotice('Saved!');
		}

		$request -> response = View::render('core/html/admin/edit', $data = array(
			'form' => $form,
			'title' => 'Signup Process'
		));
	}

}
